<?php
//调取属性值显示的模板
class attrFormModel extends Model{
	public $table="add_goods_type";
	public function attrForm($gtid){
            //获得属性值
            $attrClassData=M("g_attr_class")->where(array("add_goods_type_aid"=>$gtid,"is_spec"=>2))->all();
            if($attrClassData){
               foreach($attrClassData as $n=>$attrClass){
                   $attrValue=M("g_arr_value")->where(array("g_attr_class_ac_id"=>$attrClass["ac_id"]))->all();
                   $func=$attrClass["show_type"];
                   if(method_exists($this,$func)){
                    $attrClassData[$n]['html']=$this->$func($attrValue);
                   }
               }
                return $attrClassData;
            }

	 }

         //input模型
        public function input($attrValue){
              $html="<input  type='text' name='attr[{$attrValue[0]['g_attr_class_ac_id']}|{$attrValue[0]['av_id']}]' value='{$attrValue[0]['av_name']}'  class='w300'  >";
              return $html;
        }

        //box模型
        public function box($attrValue){
        	$html="<select name='attr[]'>";
        	 foreach ($attrValue as $Value){
        		$html.="<option value='{$Value['av_id']}|{$Value['av_name']}'>{$Value['av_name']}</option>";
        	};
        	$html.="</select>";
          return $html;
        }

}





